﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net;
using System.IO;
using Meeting.Model;
using Newtonsoft.Json;

namespace Meeting.Web.ashx
{
    /// <summary>
    /// ResponseVideoStatus 的摘要说明
    /// </summary>
    public class ResponseVideoStatus : IHttpHandler
    {
        string methodName = "";
        bool jsonP = false;
        public void ProcessRequest(HttpContext context)
        {
            JsonResponse response = new JsonResponse();
            String header = "{0}";
            try
            {
                String cb = context.Request.Params["callback"]; //  
                //传过来的 callback 参数 假如 Ext.data.JsonP.callback  
                if (cb != null)
                {
                    jsonP = true;
                    context.Response.ContentType = "text/javascript";
                }
                else
                {
                    context.Response.ContentType = "application/x-json;charset=utf-8";
                }

                header = "";
                if (jsonP)
                {
                    header = cb + "({0})";
                }
                else
                {
                    header = "{0}";
                }

                string hostEmail = context.Request.Params["hostEmail"];
                string hostPass = context.Request.Params["hostPass"];
                BLL.VideoRoom vrBll = new BLL.VideoRoom();
                response.success = true;
                response.ResponseData = vrBll.GetVideoRoomStatus(hostEmail, hostPass);
                context.Response.Write(JsonConvert.SerializeObject(response));
            }
            catch (Exception ex)
            {
                response.success = false;
                response.Message = ex.Message;
                context.Response.Write(JsonConvert.SerializeObject(response));
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}